************************************************* 
** Stata code to construct Supplement Table A2 **
************************************************* 

global stataout [specify local folder for figures and tables]


run "prep3.do"

use "Patreg.dta", clear
get_coef "ppmlhdfe cites_others CAFC_post $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "ppmlhdfe cites_others CAFC_post $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
outreg2 using "tableA2", word replace nor2 noobs  /// 
      addtext("Year-Technology-Industry FE", ///
	"Yes", "Circuit FE", "Yes") ///
	addstat( "Patents", nobs, ///
	  "Companies", cmp, "Chi-squared", chi2, ///
	  "Economic effect", perct) ///
	  sortvar(_b_CAFC_post  _b_emp_ln _b_revt_per_inh _b_ppe_per_inh _b_xrd_per_inh ///
	_b_tobin  _b_nclaims   _b_nciting_inh  ///
	  _b_cons) bdec(3) tdec(3)  ///
	  ctitle("All")  
	
use "Patreg.dta", clear
get_coef "ppmlhdfe cites_others CAFC_post CAFC_post_prod CAFC_prod $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "ppmlhdfe cites_others CAFC_post CAFC_post_prod CAFC_prod $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout" 
reg_out_count "tableA2" "Effectiveness: Product"

use "$stata\CAFC\Patreg.dta", clear
get_coef "ppmlhdfe cites_others CAFC_post CAFC_post_proc CAFC_proc $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "ppmlhdfe cites_others CAFC_post CAFC_post_proc CAFC_proc $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out_count "tableA2" "Effectiveness: Process"
  

